# coding=utf-8
# 代码文件：chapter6/ch6.2.7.py

import matplotlib.pyplot as plt
import pandas as pd

plt.rcParams['font.family'] = ['SimHei']    # 设置中文字体
plt.rcParams['axes.unicode_minus'] = False  # 设置负号显示

plt.figure(figsize=(15, 5))

f = r'data\股票历史交易数据.xlsx'
df = pd.read_excel(f)

df2 = df.query("Date >='2021-03-01' and Date < '2021-04-01'").sort_values(by='Date')

plt.title('贵州茅台股票OHLC折线图')
plt.plot(df2['Date'], df2['Open'], label='开盘价')
plt.plot(df2['Date'], df2['High'], label='最高价')
plt.plot(df2['Date'], df2['Low'], label='最低价')
plt.plot(df2['Date'], df2['Close'], label='收盘价')

plt.ylabel('成交量')
plt.xlabel('交易日期')
plt.xticks(rotation=40)

plt.show()
